home *** CD-ROM | disk | FTP | other *** search
- Path: news.cs.ucla.edu!twinsun!not-for-mail
- From: eggert@twinsun.com (Paul Eggert)
- Newsgroups: comp.lang.c,comp.lang.c++,gnu.gcc.help,gnu.g++.help,comp.os.msdos.djgpp
- Subject: Re: float != float and floats as return types
- Date: 2 Feb 1996 12:57:08 -0800
- Organization: Twin Sun Inc, El Segundo, CA, USA
- Message-ID: <4ettr4$al5@der.twinsun.com>
- References: <4ej9lb$mpc@fu-berlin.de> <4elnjj$er4@server2.rz.uni-leipzig.de> <4eqc7l$ugh@godzilla.zeta.org.au> <4eqtu3$ddo@der.twinsun.com> <TANMOY.96Feb1164022@qcd.lanl.gov>
- NNTP-Posting-Host: der.twinsun.com
-
- tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya) writes:
-
- > I do not agree with this interpretation, as the footnote (technically,
- > not part of the standard) clarifies: an assignment and cast both must
- > truncate the result to the required precision.
-
- Sorry, that footnote doesn't clarify matters. All the footnote says
- is that the required conversions must be performed. In the example
- we're talking about, there's no conversion to be performed, since
- both sides of the assignment have `float' type.
-
- Furthermore, even if there is a conversion, I don't see where the standard
- requires that excess precision be discarded. All the standard requires is
- that the result be ``represented exactly''; it doesn't say what it means
- by this, and an implementation that keeps excess precision is certainly
- representing _its_ result exactly. The standard explicitly licenses
- excess precision, and never explicitly (or implicitly, as far as I can
- see) requires excess precision to be discarded.
-
- Also please see ANSI C 3.3.4, which says ``A cast that specifies no
- conversion has no effect on the type or value of the expression'';
- this means that an implementation with extra precision is not allowed
- to discard it because of a cast of float to float. It is natural to
- assume that assignment of float to float can behave similarly to a cast.
-
- I realize that the standard is muddled in this area -- for example, the
- Rationale contradicts it, and I've been told that the C Standard committee
- may amend 3.3.4 because of the problem with floating point casts
- (surely an implementation should be allowed to discard excess precision
- whenever it wants to).
-
- That being the case, I think it wise for users not to rely on the fine
- points here, and my advice to the GCC implementers is to hold off on
- changing GCC's behavior until the C Standard committee acts.
-